<?php echo $header;echo $sidebar ?>		

	<style>
		select {background-color: #FFFFFF;border: 1px solid #CCCCCC;width: 100% !important;}
		.clear{clear: both;}
	</style>
	
	<div class="span10 content">

		<?php echo $hugemenu ?>

		<h1>Create New Ticket</h1>

		<?php if($this->session->flashdata('message')) :?>
			<div class="alert alert-success">
				<?php echo $this->session->flashdata('message') ?>
			</div>
		<?php endif; ?>
		
		<?php #if($message) { echo "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $message . "</div>"; } ?>

		<div class="widget">
			<div class="widget-head"><h3 class="heading">New Ticket</h3></div>
			<div class="widget-body">
				 <div class="row-fluid">
                    <div class="span6">
			
							<?php 
					        $error = $this->session->flashdata('error');
					            	
					        if($error)
					        {
					        	echo "<div class='alert alert-danger'>{$error}</div>";
					        } ?>
					        
					        <form id="create-ticket-form" class="form-horizontal" action="<?php echo base_url(); ?>index.php/tickets/insert" method="post">
								<div class="form-group">
									<label>Title *</label>
									<div style="margin-bottom:15px;"><input name="title" type="text" autocomplete="off" class="form-control" value="<?php echo $this->session->flashdata('backfill_title'); ?>" style="width:98%;" /></div>
								</div>
								
								<div class="form-group">
									<label>Assigned To *</label>
									<div style="margin-bottom:15px;">
									<select name="assigned[]" style="width:98%;" multiple>
										<?php
										for($i = 0; $i < count($users); ++$i)
										{ ?>
											<option value="<?php echo $users[$i]['id']; ?>"><?php echo $users[$i]['first_name'].' '.$users[$i]['last_name']; ?></option>
										<?php
										} ?>
									</select>
									</div>
								</div>
								
								<div class="form-group">
									<label>Severity *</label>
									<div style="margin-bottom:15px;">
									<select name="severity" class="form-control">
										<?php
										$critical = null;
										$high = null;
										$medium = null;
										$low = null;
					
										if($this->session->flashdata('backfill_severity') == '104')
										{
											$critical = "selected='selected'";
										}
										elseif($this->session->flashdata('backfill_severity') == '105')
										{
											$high = "selected='selected'";
										}
										elseif($this->session->flashdata('backfill_severity') == '106')
										{
											$medium = "selected='selected'";
										}
										elseif($this->session->flashdata('backfill_severity') == '107')
										{
											$low = "selected='selected'";
										} ?>
										
										<option value="104" <?php echo $critical; ?>>Critical</option>
										<option value="105" <?php echo $high; ?>>High</option>
										<option value="106" <?php echo $medium; ?>>Medium</option>
										<option value="107" <?php echo $low; ?>>Low</option>
									</select>
									</div>
								</div>
								
								<div class="form-group">
									<label>Department *</label>
									<div style="margin-bottom:15px;">
									<select name="department" class="form-control">
										<?php
										for($i = 0; $i < count($departments); ++$i)
										{ 
											if($this->session->flashdata('backfill_department') == $departments[$i]['department_id'])
											{ ?>
												<option selected="selected" value="<?php echo $departments[$i]['department_id']; ?>"><?php echo $departments[$i]['department_name']; ?></option>
											<?php 
											} 
											else 
											{ ?>
												<?php 
												if(!$this->session->flashdata('backfill_department') && $defaults[0]['company_default_department_id'] == $departments[$i]['department_id'])
												{ ?>
													<option selected="selected" value="<?php echo $departments[$i]['department_id']; ?>"><?php echo $departments[$i]['department_name']; ?></option>
												<?php 
												} 
												else
												{ ?>
													<option value="<?php echo $departments[$i]['department_id']; ?>"><?php echo $departments[$i]['department_name']; ?></option>
												<?php 
												}
											}
										} ?>
									</select>
									</div>
								</div>
								
								<div class="form-group">
									<label>Project *</label>
									<div style="margin-bottom:15px;">
									<select name="project" class="form-control">
										<?php
										for($i = 0; $i < count($projects); ++$i)
										{ 
											if($this->session->flashdata('backfill_project') == $projects[$i]['project_id'])
											{ ?>
												<option selected="selected" value="<?php echo $projects[$i]['project_id']; ?>"><?php echo $projects[$i]['project_name']; ?></option>
											<?php 
											} 
											else
											{ ?>
												<?php 
												if(!$this->session->flashdata('backfill_project') && $defaults[0]['company_default_project_id'] == $projects[$i]['project_id'])
												{ ?>
													<option selected="selected" value="<?php echo $projects[$i]['project_id']; ?>"><?php echo $projects[$i]['project_name']; ?></option>
												<?php 
												} 
												else
												{ ?>
													<option value="<?php echo $projects[$i]['project_id']; ?>"><?php echo $projects[$i]['project_name']; ?></option>
												<?php
												}
											}
										} ?>
									</select>
									</div>
								</div>
								
								<div class="form-group">
									<label>Process *</label>
									<div style="margin-bottom:15px;">
									<select name="process" class="form-control">
										<?php
										for($i = 0; $i < count($processes); ++$i)
										{ 	
											if($this->session->flashdata('backfill_process') == $processes[$i]['process_id'])
											{ ?>
												<option selected="selected" value="<?php echo $processes[$i]['process_id']; ?>"><?php echo $processes[$i]['process_name']; ?></option>
											<?php 
											} 
											else 
											{ ?>
												<?php 
												if(!$this->session->flashdata('backfill_process') && $defaults[0]['company_default_process_id'] == $processes[$i]['process_id'])
												{ ?>
													<option selected="selected" value="<?php echo $processes[$i]['process_id']; ?>"><?php echo $processes[$i]['process_name']; ?></option>
												<?php 
												} 
												else
												{ ?>
													<option value="<?php echo $processes[$i]['process_id']; ?>"><?php echo $processes[$i]['process_name']; ?></option>
												<?php
												}
											}
										} ?>
									</select>
									</div>
								</div>
								
								<div class="form-group">
									<label>Due By *</label>
									<div style="margin-bottom:15px;">
									<?php 
									if($this->session->flashdata('backfill_completion'))
									{ ?>
									<input name="completion" type="text" class="form-control datepicker" data-date-format="mm/dd/yy" value="<?php echo $this->session->flashdata('backfill_completion'); ?>" style="width:98%;">
									<?php 
									} 
									else
									{ ?>
										<input name="completion" type="text" class="form-control datepicker" data-date-format="mm/dd/yy" value="<?php echo date("m/d/y", strtotime(date("Y-m-d H:i:s"))); ?>" style="width:98%;">
									<?php 
									} ?>
									</div>
								</div>
								
								<div class="form-group">
									<label>Hours Allotted</label>
									<div style="margin-bottom:15px;"><input name="hours_allotted" type="text" class="form-control" autocomplete="off" value="<?php echo $this->session->flashdata('backfill_allotted'); ?>" style="width:98%;" /></div>
								</div>
								
								<div class="form-group">
									<label>Description of Issue</label>
									<div style="margin-bottom:15px;"><textarea name="description" class="form-control" rows="8" style="width:98%;"><?php echo $this->session->flashdata('backfill_description'); ?></textarea></div>
								</div>
								
								<div class="clear"></div>
								<div class="form-group">
									<button type="submit" class="btn btn-primary pull-left">Create</button>
								</div>
							</form>
					</div>
				</div>
			</div>
		</div>
		
		
	</div><!--/content-->

<?php echo $footer ?>